package cn.cdeden.knowledge.mapper;

import cn.cdeden.knowledge.domain.TeamType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* @author Chen
* @date 2024-04-19
*/
@Repository
public interface TeamTypeMapper extends BaseMapper<TeamType> {

    @Select("SELECT t1.id,t1.NAME ,(\n" +
            "SELECT count(*) FROM team_relevance_type t2 WHERE t1.id=t2.type_id) AS 'count' FROM team_type t1")
    @MapKey("id")
    Map selectTypeCount();

    List<TeamType> getByTeamId(Integer teamId, Long userId);
}
